import socket


socket= socket.socket(socket.AF_INET, socket.SOCK_STREAM)

#2.连接服务端
socket.connect(('127.0.0.1',8080))
socket.send('connection'.encode('utf-8'))

#3.接收数据
msg = socket.recv(1024)#阻塞
print('Server:',msg.decode('utf-8'))

#4.向服务端发送数据

socket.send('你好,小爱同学,我想听一首一剪梅'.encode('utf-8'))

#5.关闭
socket.close()